import 'package:development_assistant/config/db_config.dart';
import 'package:development_assistant/model/api_info.dart';
import 'package:sqflite/sqflite.dart';

class ApiService{
  Database database=DBConfig.getDatabase();
  String tableName="api_info";

  Future addApi(ApiInfo apiInfo) async{
    await database.insert(tableName, apiInfo.toMap());
  }

  Future delApi(int apiID) async{
    await database.delete(tableName,where: "api_id=?",whereArgs: [apiID]);
  }

  Future updateApi(ApiInfo apiInfo) async{
    await database.update(tableName, apiInfo.toMap(),where:"api_id=?",whereArgs: [apiInfo.apiID]);
  }

  Future getApiInfo(int apiID) async{
    return await database.query(tableName,where: "api_id=?",whereArgs: [apiID]);
  }

  Future getApiList() async{
    return await database.query(tableName);
  }

}